package cn.sccl.common.model;

import cn.sccl.common.exception.BusinessException;

/**
 * 操作日志记录表
 * 数据库表 T_OPERATION_LOG 的实体对象
 * Created by 杨浩宇 on 2016-08-06.
 */
public class OperationLog extends BaseModel {
    /**
     * 表名
     */
    public final static String TABLE_NAME = "t_operation_log";

    private java.lang.String userName;//操作用户
    private java.lang.String details;//操作详情
    private java.lang.Long type;//操作类型

    public java.lang.String getUserName() {
        return this.userName;
    }

    public void setUserName(java.lang.String userName) {
        this.userName = userName;
    }

    public java.lang.String getDetails() {
        return this.details;
    }

    public void setDetails(java.lang.String details) {
        this.details = details;
    }

    public java.lang.Long getType() {
        return this.type;
    }

    public void setType(java.lang.Long type) {
        this.type = type;
    }

    /**
     * clone一个对象。
     *
     * @param cls 需要克隆的对象类型，只能是当前类的子类
     * @param <T>
     * @return
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public <T extends OperationLog> T clone(Class
                                                    <T> cls) {
        try {
            T t = cls.newInstance();
            t.setId(this.
                    getId());
            t.setCreateTime(this.
                    getCreateTime());
            t.setUpdateTime(this.
                    getUpdateTime());
            t.setDeleteFlag(this.isDeleteFlag());
            t.setUserName(this.
                    getUserName());
            t.setDetails(this.
                    getDetails());
            t.setType(this.
                    getType());
            return t;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("对象克隆失败，请克隆的目标对象是否具有无参的构造函数。", e.getCause());
        }
    }
}